package com.webex.ta.hydra.gui.project;

import com.webex.ta.hydra.gui.table.HydraTable;
import com.webex.ta.hydra.gui.table.HydraTableModel;
import com.webex.ta.hydra.gui.HydraEditorPane;
import com.webex.ta.hydra.core.TestPlan;

import java.io.File;

/**
 * Author: Vegaz
 * Date: 2010-11-8
 * Time: 16:49:36
 */
public class HydraProjectSuite {
    private String name;
    private File file;
    private HydraEditorPane editorPane;
    private HydraTable table;
    private HydraTableModel model;

    private TestPlan snapshot;


    public HydraProjectSuite() {
        editorPane = new HydraEditorPane();
        table = editorPane.getTable();
        model = table.getModel();
    }

    

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        if (file != null) {
            this.file = file;
            name = file.getName();
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public HydraEditorPane getEditorPane() {
        return editorPane;
    }

    public void setEditorPane(HydraEditorPane editorPane) {
        this.editorPane = editorPane;
    }

    public HydraTable getTable() {
        return table;
    }

    public HydraTableModel getModel() {
        return model;
    }

    public void takeSnapshot() {
        snapshot = model.getTestPlan().clone();
    }

    public boolean isDirty() {
        return !model.getTestPlan().isEqualWith(snapshot);
    }

    public static class ProjectNameSequencer {
        private static int seq = 0;
        public static String nextProjectName() {
            seq++;
            return "New Project " + seq;
        }
    }
}
